package com.sunnada.edu.system.sysdict.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sunnada.edu.system.pub.common.Common;
import com.sunnada.edu.system.sysdict.dao.SysDictDao;

@Service
@Transactional
public class SysDictServiceImpl implements SysDictService {
	private static final Logger logger = LoggerFactory.getLogger(SysDictServiceImpl.class);
	@Resource
	SysDictDao dictDao;

	@Override
	public int getDictCots(HashMap<String, String> params) {
		return dictDao.getDictCots(params);
	}

	@Override
	public List<?> findDicts(HashMap<String, String> params) {
		return dictDao.findDicts(params);
	}

	@Override
	public String dictDelete(HashMap<String, String> params) {
		String msg = "";
		int num = dictDao.dictDelete(params);
		if (num == 0) {
			msg = "删除失败!";
		}
		return msg;
	}

	@Override
	public String dictAdd(HashMap<String, String> params) {
		String msg = "";
		params.put("recId", Common.getSeqId("BASE_SEQ"));
		int num = dictDao.dictAdd(params);
		if (num == 0) {
			msg = "添加失败!";
		}
		return msg;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String dictUpdate(HashMap<String, String> params) {
		String msg = "";
		int num = dictDao.dictUpdate(params);
		if (num == 0) {
			msg = "修改失败!";
		} 
		return msg;
	}

	@Override
	public Map getDictByRecId(HashMap<String, String> params) {
		return dictDao.getDictByRecId(params);
	}

	@Override
	public List getDictTypeList(HashMap<String, String> params) {
		return SysDictMethods.getDictTypeList(params);
	}

	@Override
	public String typeAdd(HashMap<String, String> params) {
		SysDictMethods.typeAdd(params);
		return null;
	}
	
	@Override
	public int getDictTypeCots(HashMap<String, String> params) {
		return dictDao.getDictTypeCots(params);
	}

	@Override
	public List<?> findDictTypes(HashMap<String, String> params) {
		return dictDao.findDictTypes(params);
	}
	
	@Override
	public Map getDictTypeByRecId(HashMap<String, String> params) {
		return dictDao.getDictTypeByRecId(params);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public String typeUpdateSave(HashMap<String, String> params) {
		String msg = "";
		int num = dictDao.typeUpdateSave(params);
		if (num == 0) {
			msg = "修改失败!";
		} 
		return msg;
	}
	
	@Override
	public String dictTypeDelete(HashMap<String, String> params) {
		String msg = "";
		int num = dictDao.dictTypeDelete(params);
		if (num == 0) {
			msg = "删除失败!";
		}
		return msg;
	}
	

}
